package com.ycsj.goldmedalnewconcept.teacher.utils;

import android.content.Context;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;

/**
 * 文字变色处理类
 * Created by Administrator on 2019/2/21 0021.
 */

public class TextUtil {
    /**
     * @param context
     * @param text      文字内容
     * @param colorText 需要变色文字
     * @return
     */
    public static CharSequence setColor(Context context, String text, String colorText, int colorId) {
        SpannableStringBuilder style = new SpannableStringBuilder(text);
        style.setSpan(new ForegroundColorSpan(context.getResources().getColor(colorId)), 0, colorText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        return style;
    }
}
